﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using eShop.Business;
using System.Text;
using System.Web.UI.HtmlControls;
using eShop.Model;
using eShop.Business;
using eShop.Utility;

public partial class controls_wucProductCategoryListingHome : System.Web.UI.UserControl
{
    public String ProductPath
    {
        get
        {
            try
            {
                return Page.RouteData.Values["path"].ToString();
            }
            catch
            {
                return string.Empty;
            }
        }
    }

    public int RepeatedColumns
    {
        get { return _repeatedColumns; }
        set { _repeatedColumns = value; }
    }

    public int MaxItem
    {
        get { return _maxItem; }
        set { _maxItem = value; }
    }

    protected StringBuilder MyData = new StringBuilder();
    private int _repeatedColumns = 3;
    private int _maxItem = 9;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void LoadListing(string catName)
    {        
        LoadRepeaterItems(catName);
        siteBanner.CategoryPath = catName;
        siteBanner.LoadWidget();
    }

    protected void LoadRepeaterItems(string catName)
    {
        Category cat = CategoryManager.GetByCategoryUrl(catName);
       
        if (cat != null)
        {
            litParentCat.Text = cat.CategoryName.ToUpper();
            List<Product> product = ProductManager.GetProductByCategoryURL(catName);
            if (product != null)
            {
                productList.DataSource = product;
                productList.DataBind();
            }
        }
    }
}